<template>
	<view class="content">
		<view class="main">
			<view class="text" v-html="text"></view>
		</view>
	</view>
</template>

<script>
	import common from '@/static/js/common';

	export default {
		data() {
			return {
				type: '',
				text: '',
				typeObj:{
					register: '用户注册协议',
					privacy: '隐私政策',
					copyright: '版权声明',
					exemption: '免责声明',
					specification: '广告规范',
					upgrade: '升级规则协议'
				}
			}
		},
		onLoad(e) {
			this.type = e.type;
			if (this.typeObj[e.type]) {
				uni.setNavigationBarTitle({title: this.typeObj[e.type]})
			}
			this.getAgreementInfo();
		},
		methods: {
			getAgreementInfo () {
				let that = this;
				common.api({
					method: 'GET',
					url: '/mobile/index/agreement',
					data: {
						code: that.type
					},
					success: function(result) {
						if (result.code != 0) {
							uni.showToast({ title: result.msg, icon: 'none' });
							return false;
						}
						that.text = result.data.content;
					},
					error: function () {
						uni.showToast({ title: '数据请求异常', icon: 'none' });
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		background-color: #fff;
		min-height: 100%;
	}
	.text{
		padding: 20rpx 30rpx;
		color: #666;
		font-size: 32rpx;
		text-align: justify;
	}
</style>
